package com.us.usws.site.ws.resource;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import com.us.usws.model.domain.box.BoxTheme;
import com.us.usws.service.ro.BoxThemeROService;
import com.us.usws.service.ro.MeetingROService;
import com.us.usws.site.ws.entity.WSEntity;
import com.us.usws.site.ws.entity.theme.WSThemeEntityPackGenerator;
import com.us.usws.support.uitls.ServiceFactory;

/**
 * User webservice
 */
@Path("/themes")
public class ThemeResource {

	//private static Log log = LogFactory.getFactory().getInstance(ChannelResource.class);

	private BoxThemeROService bS = ServiceFactory.getInstance().getService(BoxThemeROService.class);
	private MeetingROService mS = ServiceFactory.getInstance().getService(MeetingROService.class);

	@GET
	@Path("/{themeUid}.json")
	//@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
	@Produces(MediaType.APPLICATION_JSON)
	public WSEntity getThemeInfo(@PathParam("themeUid") String themeUid, @QueryParam("movie_count") int maxVideoCnt,
			@QueryParam("meeting_count") int maxMeetingCnt) {

		BoxTheme m = bS.getBoxTheme(themeUid);
		if (m != null && m.getMeetings() != null) {
			mS.fillMeetingNamesInList(m.getMeetings());
		}

		WSEntity ret = WSThemeEntityPackGenerator.getInstance().getThemeDetailPack(m);

		return ret;
	}
}
